// 数据同步相关的mutations
export default {
  // 设置同步状态
  SET_IS_SYNCING(state, syncing) {
    state.isSyncing = syncing
  },
  
  // 设置同步详细状态
  SET_SYNC_STATUS(state, status) {
    state.syncStatus = status
  },
  
  // 设置同步历史
  SET_SYNC_HISTORY(state, history) {
    state.syncHistory = history
  },
  
  // 设置加载状态
  SET_LOADING(state, loading) {
    state.loading = loading
  },
  
  // 设置错误信息
  SET_ERROR(state, error) {
    state.error = error
  },
  
  // 设置同步进度
  SET_PROGRESS(state, progress) {
    state.progress = progress
  },
  
  // 设置最后同步时间
  SET_LAST_SYNC_TIME(state, time) {
    state.lastSyncTime = time
  },
  
  // 添加同步历史记录
  ADD_SYNC_HISTORY(state, record) {
    state.syncHistory.unshift(record)
    // 保持历史记录不超过100条
    if (state.syncHistory.length > 100) {
      state.syncHistory.pop()
    }
  },
  
  // 清空同步状态
  CLEAR_SYNC_STATUS(state) {
    state.syncStatus = null
    state.progress = 0
  },
  
  // 清空同步历史
  CLEAR_SYNC_HISTORY(state) {
    state.syncHistory = []
  },
  
  // 重置同步模块状态
  RESET_SYNC_STATE(state) {
    state.isSyncing = false
    state.syncStatus = null
    state.loading = false
    state.error = null
    state.progress = 0
  }
}